// store "商店" 提供 项目中共享的数据
import {defineStore} from "pinia";
// use开头 Store结尾  创建 Store 对象
export const useCartStore = defineStore('cart', {
	state: () => {
		return {
			items: [
				{id: 1, name: '魅族', price: 399}
			]
		}
	},
	getters: {
		getItems(state) {
			return state.items ? state.items : []
		}
	},
	actions: {
		addItem(item) {
			this.items.push(item)
		}
	}
})